/*
 * Copyright (c) 2015. 石头哥哥
 */

package com.comom.manager.model;

/**
 * Created by 石头哥哥 on 15/7/18.
 * PROJECT_NAME: server-java-mengchong
 * PACKAGE_NAME: com.mengchong.server.model.vo
 * COMMENT : 手机验证码
 */
public class ValidCode {

    /**
     * 验证码过期时间 5分钟
     */
    public static final long expiredTime=300000L;

    /**
     * 获取验证码
     */
    private String code;

    /**
     * 验证码失效时间
     */
    private long endTime;


    /**
     *
     * @param code
     */
    public ValidCode(String code){
        this.code=code;
        this.endTime=System.currentTimeMillis()+expiredTime;//初始化过期时间
    }

    /**
     * 验证码是否有效
     * @return  true is valid
     */
    public boolean isValid(){
        return System.currentTimeMillis()<=endTime;
    }


    /**
     *
     * @return
     */
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }
}
